package org.springblade.modules.repair.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.modules.repair.entity.MaintainPlanContentUser;
import org.springblade.modules.repair.enums.MaintainPlanContentEnum;
import org.springblade.modules.repair.enums.RescueArriveEnum;
import org.springblade.modules.repair.enums.TaskStatusEnum;

import java.util.Date;
import java.util.List;

/**
 * @Date 11:09 2023/2/27
 * @Description {
 *   首页救援工单详情
 * }
 * @Author lsay
 **/
@Data
public class MalfunctionRescueDetailHomeListVO {

	/**
	 * 工单id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	private Long planId;

	/**
	 * 电梯id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	private Long elevatorId;

	/**
	 * 工单类型
	 */
	private Integer typeStatus;

	/**
	 * 工单类型描述
	 */
	private String typeStatusDesc;

	/**
	 * 报警类型
	 */
	private Integer trapType;

	/**
	 * 报警类型描述
	 */
	private String trapTypeDesc;

	/**
	 * 报警备注
	 */
	private String trapDesc;

	/**
	 * 报警时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	/**
	 * 工单状态
	 */
	private Integer status;

	/**
	 * 工单状态描述
	 */
	private String statusDesc;

	/**
	 * 电梯地址
	 */
	private String elevatorAddress;

	/**
	 * 服务器时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date serviceDate;

	/**
	 * 关联人员列表
	 */
	private List<MaintainPlanContentUser> planContentUsers;

	@ApiModelProperty(value = "到达时间最大阔值")
	private Date maximumArrivalTime;

	@ApiModelProperty(value = "救援要求时间类型 0-默认（30min），1-项目")
	private Integer maximumType;

	@ApiModelProperty(value = "到达预警状态")
	private Integer arrivalWarning;

	@ApiModelProperty(value = "到达预警状态名称")
	private String arrivalWarningDesc;

	@ApiModelProperty(value = "到达预警状态触发时间")
	private Date arrivalWarningTime;

	public void setTrapType(Integer trapType) {
		if (trapType == 1) {
			this.trapTypeDesc = "伤人";
		} else {
			this.trapTypeDesc = "困人";
		}
		this.trapType = trapType;
	}

	public void setTypeStatus(Integer typeStatus) {
		this.typeStatusDesc = MaintainPlanContentEnum.getName(typeStatus);
		this.typeStatus = typeStatus;
	}

	public void setStatus(Integer status) {
		this.statusDesc = TaskStatusEnum.getTaskName(MaintainPlanContentEnum.MAINTAIN_KR.getId(), status);
		this.status = status;
	}

	public void setArrivalWarning(Integer arrivalWarning) {
		this.arrivalWarning = arrivalWarning;
		if (arrivalWarning != null && arrivalWarning > 0) {
			this.arrivalWarningDesc = RescueArriveEnum.getName(arrivalWarning);
		}
	}
}
